<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";

const user = ref({});
const router = useRouter();

const login = () => {
  if (user.value.username === "admin" && user.value.password === "admin@123") {
    router.push("/index");
  } else {
    alert("登录失败");
  }
};
</script>

<template>
  <div>
    <label for="username">用户名：</label>
    <input id="username" v-model="user.username" />
  </div>
  <div>
    <label for="password">密码：</label>
    <input type="password" id="password" v-model="user.password" />
  </div>
  <div>
    <button @click="login">登录</button>
  </div>
</template>
